<!-- 人脉列表 -->
<template>
  <a-card :bordered="false" class="br-10">
    <div class="table-page-search">
      <a-form>
        <a-form-item label="关键字">
          <a-input v-model="queryParam.keyWord" placeholder="请输入" allowClear />
        </a-form-item>
        <a-form-item label="协会类型">
          <a-select v-model="queryParam.assType" default-value="lucy" style="width: 120px" @change="handleChange">
            <a-select-option value="jack"> Jack </a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="入会时间">
          <a-range-picker format="YYYY-MM-DD" valueFormat="YYYY-MM-DD" v-model="applyTime" class="width-25" />
        </a-form-item>
        <span class="search-submitButtons">
          <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
          <a-button @click="handleReset">重置</a-button>
        </span>
      </a-form>
    </div>
    <div v-has="'business:people:peopleList:export'" class="table-operator disFlxJS">
      <div>
        <a-button type="primary" @click="handleExportExcel">导出</a-button>
      </div>
    </div>
    <s-table
      ref="table"
      size="default"
      rowKey="id, enabled, title"
      :columns="columns"
      :data="loadData"
      :rowSelection="null"
    >
      <!-- 序号 -->
      <span slot="serial" slot-scope="text, record, index">
        {{ (pagination.current - 1) * pagination.pageSize + parseInt(index) + 1 }}
      </span>
      <!-- 审核状态 -->
      <span slot="auditStatus" slot-scope="text">
        <DictTag :options="Dict.getLocal('reviewStatusDict')" :value="text" />
      </span>
      <!-- 缴费情况 -->
      <span slot="paymentStatus" slot-scope="text">
        <DictTag :options="Dict.getLocal('paymentStatusDict')" :value="text" />
      </span>
    </s-table>
  </a-card>
</template>

<script>
import { STable } from '@/components'
import { LeadingPage } from '@/api/business/source'
import DictTag from '@/components/DictTag'

export default {
  components: {
    STable,
    DictTag,
  },
  data() {
    return {
      pagination: {
        current: 1,
        pageSize: 10,
      },
      queryParam: {
        keyWord: undefined,
        contactsType: 1,
        assType: 0,
      },
      columns: [
        {
          title: '序号',
          scopedSlots: { customRender: 'serial' },
          width: '80px',
        },
        {
          title: '组织名称',
          dataIndex: 'proposer',
          ellipsis: true,
          width: '180px',
        },
        {
          title: '入会时间',
          dataIndex: 'levelName',
          ellipsis: true,
          width: '150px',
        },
        {
          title: '申请职务',
          dataIndex: 'auditStatus',
          ellipsis: true,
          scopedSlots: { customRender: 'auditStatus' },
          width: '150px',
        },
        {
          title: '缴费情况',
          dataIndex: 'paymentStatus', //1:已缴费，0:待缴费
          ellipsis: true,
          scopedSlots: { customRender: 'paymentStatus' },
          width: '150px',
        },
        {
          title: '提交人',
          dataIndex: 'userName',
          ellipsis: true,
          width: '150px',
        },
        {
          title: '提交人手机',
          dataIndex: 'phonenumber',
          ellipsis: true,
          width: '150px',
        },
        {
          title: '审核人',
          dataIndex: 'auditUserName',
          ellipsis: true,
          width: '150px',
        },
        {
          title: '提交时间',
          dataIndex: 'createTime',
          ellipsis: true,
          width: '200px',
        },
        {
          title: '审核时间',
          dataIndex: 'auditTime',
          ellipsis: true,
          width: '200px',
        },
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: async (parameter) => {
        var params = {
          current: parameter.pageNum,
          size: parameter.pageSize,
        }
        return LeadingPage(Object.assign(params, this.queryParam))
          .then((res) => {
            if (res.code === 0) {
              this.pagination.current = parameter.pageNum
              this.pagination.pageSize = parameter.pageSize
              return res
            } else {
              this.$message.error(res.msg)
            }
          })
          .catch((err) => {
            this.$message.error(err.msg)
          })
      },
      stageList: [],
    }
  },
  computed: {
    applyTime: {
      get() {
        return [this.queryParam.startTime, this.queryParam.endTime]
      },
      set(val) {
        this.queryParam.startTime = val[0]
        this.queryParam.endTime = val[1]
      },
    },
  },
  created() {},
  methods: {
    handleReset() {
      Object.keys(this.queryParam).forEach((k) => {
        this.queryParam[k] = undefined
      })
      this.$refs.table.refresh(true)
    },
    async handleExportExcel() {
      await memberApplyFormExportExcel()
    },
  },
}
</script>
<style scoped lang="less"></style>
